const { JSONParse, JSONStringify } = require("./tool");

function parseJsonByKeys(data = {}, keys = []) {
  const newData = { ...data };
  keys.forEach((key) => {
    newData[key] = JSONParse(data[key]);
  });
  return newData;
}

function stringifyJsonByKeys(data = {}, keys = []) {
  const newData = { ...data };
  keys.forEach((key) => {
    newData[key] = JSONStringify(data[key]);
  });
  return newData;
}

module.exports = {
  parseJsonByKeys,
  stringifyJsonByKeys,
};
